-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce right types for spec-reserved keys #39
Enforce right types for spec-reserved keys #39
Conversation
Hi @armaganyildirak just checked -after my review- that this PR is not finished. Two things that you can do to signal this in a more clear way (one, the other or both):
If you want a partial review, while still in progress, keep it as a draft/tagged as WIP and re-request or tag me/someone who you think could help, like age. Regarding the code itself, to begin with, you can simply follow the same path taken for the
if is_keyof_u16(key.as_ref()) {
rlp::decode::<u16>(&value).map_err(|err| EnrError::InvalidRlpData(err.to_string()))?;
} so you would, for and ipv6 key for example, do something like: if <here goes the check about the key being ipv6> {
rlp::decode::<IPv6Addr>(&value).map_err(|err| EnrError::InvalidRlpData(err.to_string()))?;
} After this the code can probable be improved further, but this is a good first step |
It's going to take some iterations before we get this right @armaganyildirak but don't get discouraged. Right now, you have changed most (if not all) the functions of the builder to return a We would get things like this: assert!(EnrBuilder::new("v4").add_value("ip6", "most definitely not an ipv6! :O").build(&key).is_err()); Now onto the In the meantime, can you restore the functions that were not Also, it would be better to add a About clippy, don't bother dealing with errors that do not relate to your code, I added the fixes for those in #42 Thanks for hanging in there |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is an overall improvement. I think we merge this and iterate later on.
Ty for the great work @armaganyildirak
Issue Addressed
Addresses #26
Proposed Changes
Checking key and value according to spec-reserved keys.
Additional Info
I have not finished the PR yet. I am still not sure about that I am following the correct idea.